﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.VisualStudio.Text.Operations;
using Logging;

namespace UWCSE.CompleterVSPackage
{
    class LoggingUndoPrimitive : ITextUndoPrimitive
    {
        private readonly string message;

        public LoggingUndoPrimitive(string message)
        {
            this.message = message;
        }

        bool ITextUndoPrimitive.CanMerge(ITextUndoPrimitive older)
        {
            return false;
        }

        bool ITextUndoPrimitive.CanRedo
        {
            get { return true; }
        }

        bool ITextUndoPrimitive.CanUndo
        {
            get { return true; }
        }

        void ITextUndoPrimitive.Do()
        {
            Logger.PrintLineWithTime("REDOING " + message);
        }

        ITextUndoPrimitive ITextUndoPrimitive.Merge(ITextUndoPrimitive older)
        {
            // Merging not supported.
            throw new NotImplementedException();
        }

        ITextUndoTransaction ITextUndoPrimitive.Parent { get; set; }

        void ITextUndoPrimitive.Undo()
        {
            Logger.PrintLineWithTime("UNDOING " + message);
        }
    }
}
